﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] temperatures = { 25, 23, 28, 32, 31 };
            try
            {
               
                Console.Write("温度值为：" + temperatures[0] + temperatures[1] + temperatures[2] + temperatures[3] + temperatures[4] + temperatures[5]);
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine("发生严重错误：" + e.Message);
            }
            finally
            {
                Console.WriteLine("执行完毕！");
            }

            //way 2:
            Console.Write("温度值为：");
            for (int i = 0; i < temperatures.Length; ++i)
            {
                Console.Write(temperatures[i] + ",");
            }
            Console.Write("\n");
            Console.Write("\n");
            //way 3:
            Console.Write("温度值为：");
            foreach (int temp in temperatures)
            {
                Console.Write(temp + ",");
            }
        }
    }
}
